﻿#ifndef _slt_tcpServer_frame_impl_220718
#define  _slt_tcpServer_frame_impl_220718

#include "SLT_tcpSenderImpl.h"
#include "SL_asynFramePub.h"

//tcp sender 管理
class SLT_tcpServerFrameImpl :public SLF_SessionBase
{
public:
	static SLT_tcpServerFrameImpl* getInst();

	SLT_TCPSenderPtr  getSender(SLTcpClientPtr &_client,const std::string& _rip, uint16_t _rport, bool reuse = true);
	SLT_tcpSenderProtocolImplSptr  newSender();

	SLT_TCPSenderPtr  getProxySender(SLTcpClientPtr &_client,const std::string& _rip, uint16_t _rport,
		                int _prefix1, int _prefix2, int _prefix3,int _devno,int _subno,const std::string &_svrid,int _encrypt,int _timeout_ms);

	int			   tryDelSender(const std::string &_senderkey);

	virtual void OnStart();
	virtual void OnStop() {}
	virtual void OnMsgArrive(SLF_senderPtr& _sender, uint32_t srcSid, int msgid, SLF_sendMemBasePtr& _data) {}
	virtual void OnTimer(uint32_t timerID, int _intervalMs, bool periodic);

	
public:
		
	std::atomic<uint32_t>   m_senderidBase{1};
	std::map<std::string, SLT_tcpSenderProtocolImplSptr>  m_senderMap;   //key 为 远端ip-port
	SLT_rwlock   m_senderMapRwlock;
};

typedef std::shared_ptr< SLT_tcpServerFrameImpl>  SLT_tcpServerFrameImplSptr;

#endif //_cac_tcp_server_220507